﻿using BMSPlatform.ViewModel;
using System.Windows;
using System.Windows.Forms;

namespace BMSPlatform
{
    /// <summary>
    /// BMSMainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class BMSMainWindow : Window
    {
        public BMSMainViewModel VM => this.DataContext as BMSMainViewModel;

        public BMSMainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //初始化界面大小
            VM.WindowWidth = Screen.PrimaryScreen.Bounds.Width * 0.7;
            VM.WindowHeight = Screen.PrimaryScreen.Bounds.Height * 0.7;
            WindowsSizeChanged(sender as Window);

        }

        private void WindowsSizeChanged(Window window)
        {
            // 获取屏幕的宽度和高度
            double screenWidth = SystemParameters.PrimaryScreenWidth;
            double screenHeight = SystemParameters.PrimaryScreenHeight;
            // 将窗口位置设置为屏幕中心
            window.Left = (screenWidth - window.Width) / 2;
            window.Top = (screenHeight - window.Height) / 2;
        }
    }
}
